package com.grandtech.insurance.service.impl;

import com.grandtech.insurance.dao.*;
import com.grandtech.insurance.domain.*;
import com.grandtech.insurance.feign.*;
import com.grandtech.insurance.service.DbKhyztjService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;


//@Component
@Transactional(rollbackFor = {Exception.class})
@Service
public class DbKhyztjServiceImpl implements DbKhyztjService {

    @Autowired
    DbKhyztjDAO dbKhyztjDAO;

    @Autowired
    DbKhyzmxDAO dbKhyzmxDAO;

    @Autowired
    DbKhxxDAO dbKhxxDAO;

    @Autowired
    DbZpsxDAO dbZpsxDAO;

    @Autowired
    SysDicDAO sysDicDAO;

    @Autowired
    DbKhdkxxDAO dbKhdkxxDAO;

    @Autowired
    NxServerBaseService nxServerBaseService;

    @Autowired
    NhgxServerBaseService nhgxServerBaseService;

    @Autowired
    Nx1ServerBaseService nx1ServerBaseService;

    @Autowired
    Nx2ServerBaseService nx2ServerBaseService;

    @Autowired
    DbDhlzxxDAO dbDhlzxxDAO;

    @Autowired
    DbJtcyxxDAO dbJtcyxxDAO;

    @Autowired
    DbYzxxDAO dbYzxxDAO;

    @Autowired
    DbZzxxDAO dbZzxxDAO;

    @Autowired
    SparkService sparkService;

    @Autowired
    DbKhyztjService dbKhyztjService;

    @Autowired
    DbZzjgDAO dbZzjgDAO;


    @Override
    public int insertSelective(DbKhyztj record) {
        return dbKhyztjDAO.insertSelective(record);
    }

    @Override
    public List<DbKhyztj> getDbKhyztjList(Map<String, Object> params) {
        return dbKhyztjDAO.getDbKhyztjList(params);
    }

    @Override
    public int getDbKhyztjCount(Map<String, Object> params) {
        return dbKhyztjDAO.getDbKhyztjCount(params);
    }

    @Override
    public int getYCCount(Map<String, Object> params) {
        return dbKhyztjDAO.getYCCount(params);
    }

    @Override
    public List<DbKhyztj> getDbKhyztjList1(Map<String, Object> params) {
        return dbKhyztjDAO.getDbKhyztjList1(params);
    }



    @Override
    public int deleteDbKhyztj(DbKhxx param) {
        return dbKhyztjDAO.deleteDbKhyztj(param);
    }

    @Override
    public int deleteDbKhyzmx(DbKhxx param) {
        return dbKhyzmxDAO.deleteDbKhyzmx(param);
    }

    @Override
    public int getDbKhyzmxCount(DbKhxx param) {
        return dbKhyzmxDAO.getDbKhyzmxCount(param);
    }

    @Override
    public int getDbKhyzmxCountAll(DbKhxx param) {
        return dbKhyzmxDAO.getDbKhyzmxCountAll(param);
    }

    //判断是否成年
    private static boolean isAdult(String str)
    {
        if (StringUtils.isEmpty(str) || (15 != str.length() && 18 != str.length()))
        {
            return false;
        } else
        {
            String birthday = str.substring(6, str.length() - 4);
            Calendar calendar = Calendar.getInstance();
            calendar.set(Integer.parseInt(birthday.substring(0, 4)) + 18,
                    Integer.parseInt(birthday.substring(4, 6)) - 1,
                    Integer.parseInt(birthday.substring(6)), 23, 59);
            long l = System.currentTimeMillis() - calendar.getTimeInMillis();
            return 0 <= l;
        }
    }

    public static void main(String[] args){
        System.out.println(isAdult(""));
    }



}













































